package com.mxpio.erp.common.inventory.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.technology.entity.ItemGroup;
import com.mxpioframework.jpa.annotation.DictAble;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "v_mb_erp_inv_flow_busi_detail_scrap")
@NoArgsConstructor
@AllArgsConstructor
@Schema(description="库存流水业务详情-报废申请")//对应财务报表
public class VInvFlowBusiDetailScrap implements DictAble, Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "ID_", updatable = false)
	@Generator
	@Schema(description = "流水号")
	private String id;

	@Column(name = "ITEM_CODE_")
	@Schema(description = "物料代码")
	private String itemCode;

	@Column(name = "DRAWING_NO_")
	@Schema(description = "图号")
	private String drawingNo;

	@Column(name = "ITEM_NAME_")
	@Schema(description = "物料名称")
	private String itemName;


	@Column(name = "ITEM_SPEC_")
	@Schema(description = "物料规格")
	private String itemSpec;

	@Column(name = "UNIT_CODE_")
	@Schema(description = "计量单位")
	@Dict(dicCode="ERP_TECH_UNIT_CODE")
	private String unitCode;

	@Column(name = "ITEM_GROUP_CODE_")
	@Schema(description = "物料组")
	@Dict(dicCode="groupCode", dicEntity = ItemGroup.class, dicText = "groupName")
	private String itemGroupCode;

	@Column(name = "MATERIAL_BRAND_")
	@Schema(description = "材料牌号")
	private String materialBrand;

	@Column(name = "MATERIAL_TYPE_")
	@Schema(description = "材料类型")
	@Dict(dicCode = "ERP_TECH_MATERIAL_TYPE")
	private String materialType;

	@Column(name = "MATERIAL_DIAMETER_")
	@Schema(description = "直径（mm）")
	private BigDecimal materialDiameter;

	@Column(name = "MATERIAL_THICKNESS_")
	@Schema(description = "壁厚（mm）")
	private BigDecimal materialThickness;

	@Column(name = "LOT_NO_")
	@Schema(description = "批次号")
	private String lotNo;

	@Column(name = "SUB_LOT_INDEX_")
	@Schema(description = "子批次索引号")//无子批默认为0
	private String subLotIndex;

	@Column(name = "QUANTITY_")
	@Schema(description = "数量")
	private BigDecimal quantity;

	@Column(name = "WH_CODE_")
	@Schema(description = "仓库编号")
	@Dict(dicCode = "whCode" ,dicEntity = Warehouse.class, dicText = "whName")
	private String whCode;

	@Column(name = "PRODUCT_ITEM_CODE_")
	@Schema(description = "产品编号")
	private String productItemCode;

	@Column(name = "PRODUCT_ITEM_NAME_")
	@Schema(description = "产品名称")
	private String productItemName;

	@Column(name = "PRODUCT_DRAWING_NO_")
	@Schema(description = "产品图号")
	private String productDrawingNo;

	@Column(name = "ACCESS_TYPE_")
	@Schema(description = "出入类型")
	@Dict(dicCode = "ERP_INV_ACCESS_TYPE")
	private String accessType;

	@Column(name = "WO_TYPE_")
	@Schema(description = "仓单类型")
	@Dict(dicCode = "ERP_INV_WO_TYPE")
	private String woType;

	@Column(name = "BUSI_BODY_CODE_")
	@Schema(description = "单位编码")
	private String busiBodyCode;

	@Column(name = "BUSI_BODY_NAME_")
	@Schema(description = "单位名称")
	private String busiBodyName;

	@Column(name = "WO_BIZ_NO_")
	@Schema(description = "仓单单号")
	private String woBizNo;

	@Column(name = "ORIGIN_BIZ_NO_")
	@Schema(description = "来源单号")
	private String originBizNo;

	@Column(name = "ORIGIN_BIZ_LINE_NO_")
	@Schema(description = "来源单行号")
	private String originBizLineNo;

	@Column(name = "ORIGIN_BIZ_TYPE_")
	@Schema(description = "来源单据类型")
	private String originBizType;

	@Column(name = "ORDER_STATUS_")
	@Schema(description = "执行状态")
	@Dict(dicCode = "ERP_COMMON_ORDER_STATUS")
	private String orderStatus;

	@Column(name = "ORDER_QANTITY_")
	@Schema(description = "订单数量")
	private BigDecimal orderQuantity;

	@Column(name = "INSPECTOR_")
	@Schema(description = "检验人")
	@Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
	private String inspector;

	@Column(name = "EXECUTOR_")
	@Schema(description = "执行人")
	@Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
	private String executor;

	@Column(name = "EXECUTE_TIME_", updatable = false)
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	@Schema(description = "执行时间")
	private Date executeTime;

	@Column(name = "CREATE_TIME", updatable = false)
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@Schema(description = "创建时间")
	private Date createTime;

	@Column(name = "SCRAP_REASON_")
	@Schema(description = "报废原因")
	private String scrapReason;

	@Column(name = "UNQUALIFIED_TYPE_")
	@Schema(description = "不合格原因类型")
	@Dict(dicCode = "ERP_QUAL_UNQUALIFIED_TYPE")
	private String unqualifiedType;

	@Column(name = "UNQUALIFIED_REASON_")
	@Schema(description = "不合格原因")
	private String unqualifiedReason;

	@Column(name = "RESPONSE_UNIT_")
	@Schema(description = "责任单位")
	private String responseUnit;

	@Column(name = "RESPONSE_PARTY_")
	@Schema(description = "责任方")
	@Dict(dicCode = "ERP_QUAL_RESPONSE_PARTY")
	private String responseParty;

	@Column(name = "RESPONSE_PERSON_")
	@Schema(description = "责任人")
	@Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
	private String responsePerson;

	@Transient
	private Map<String, String> textMap;

	public String putText(String key, String value) {
		if (textMap == null) {
			textMap = new HashMap<>();
		}
		return textMap.put(key, value);
	}
}
